import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
    state: () => {
        return {
            name: '小明',
            sex: '男',
            age: 18
        }
    },
    getters: {},
    actions: {
        changeAge() {
            this.age++
        },
        changeName() {
            this.name = '小红'
        }
    },
    persist: {
        enabled: true,
        strategies: [{
            key: 'user',
            storage: localStorage,
            paths: ['age']
        }]
    }
})